package com.example.cc;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class Modify extends Activity {
    private EditText editname = null;
    private EditText editschool = null;
    private EditText editemail = null;
    private EditText editaddress = null;
  
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.modify);
		 editname =(EditText)findViewById(R.id.editText1);
		//name = editname.getText().toString();
		 editschool =(EditText)findViewById(R.id.editText2);
		//school = editschool.getText().toString();
		 editemail =(EditText)findViewById(R.id.editText4);
		//email = editemail.getText().toString();
		 editaddress =(EditText)findViewById(R.id.editText3);
		 initView1();
		Button bns = (Button)findViewById(R.id.buttonsave);
		bns.setOnClickListener(new OnClickListener(){

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				SharedPreferences preferences01 = getSharedPreferences("file",0);
				Editor editor01=preferences01.edit();
				editor01.putString("name", editname.getText().toString());
				editor01.putString("school", editschool.getText().toString());
				editor01.putString("email",  editemail.getText().toString());
				editor01.putString("address",  editaddress.getText().toString());
				editor01.commit();
				Intent intentf = new Intent(Modify.this,file.class);
				startActivity(intentf);
			}
			
		});
	}
	private void initView1(){
		SharedPreferences preferences01 =getSharedPreferences("file",MODE_PRIVATE);
		String name =preferences01.getString("name", "");
		String school =preferences01.getString("school", "");
	    String email=preferences01.getString("email", "");
	    String address=preferences01.getString("address", "");
		editname.setText(name);
		editschool.setText(school);
		editemail.setText(email);
		editaddress.setText(address);
		
		
	}

}
